<template>
	<el-container>
		<el-aside width="220px" v-loading="showGrouploading">
			<el-tree ref="category"
					 class="menu"
					 node-key="label"
					 :data="category"
					 :props="groupsProps"
					 @node-click="updateLog"
					 :highlight-current="true"
					 :expand-on-click-node="false">
			</el-tree>
		</el-aside>
		<el-container>
			<el-main class="nopadding">
				<el-container>
					<el-header style="height: auto;">
						<sc-select-filter :data="filterData" :label-width="80" @on-change="filterChange"></sc-select-filter>
					</el-header>
					<el-header>
						<div class="left-panel">
						</div>
						<div class="right-panel">
							<el-form-item label="关联人" style="padding-top: 20px;" label-width="80px">
								<select-user-dialog v-model:accountId="search.accountId" :mode="false"/>
							</el-form-item>
							<div class="right-panel-search">
								<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
							</div>
						</div>
					</el-header>
					<el-main class="nopadding">
						<scTable ref="table" :apiObj="apiObj" row-key="logId" stripe highlightCurrentRow>
							<el-table-column label="#" type="index" width="50"></el-table-column>
							<el-table-column label="事件类型" prop="eventName" width="150"></el-table-column>
							<el-table-column label="客户端IP" prop="ip" width="150"></el-table-column>
							<el-table-column label="相关人员" prop="createUserName" width="150"></el-table-column>
							<el-table-column label="日志时间" prop="createTime" width="170"></el-table-column>
							<el-table-column label="日志摘要" prop="remark" width="300" :show-overflow-tooltip="true"></el-table-column>
						</scTable>
					</el-main>
				</el-container>
			</el-main>
		</el-container>
	</el-container>

</template>

<script>
import scSelectFilter from '@/components/scSelectFilter'
import selectUserDialog from "@/views/module/selectUserDialog.vue";
export default {
	name: 'Operation Log',
	components: {
		selectUserDialog,
		scSelectFilter
	},
	data() {
		return {
			showGrouploading: false,
			filterData: [
				{
					title: "日期范围",
					key: "date",
					multiple: false,
					options: [
						{
							label: "全部",
							value: ""
						},
						{
							label: "今日",
							value: "1"
						},
						{
							label: "昨日",
							value: "2"
						},
						{
							label: "一周内",
							value: "3"
						},
						{
							label: "一月内",
							value: "4"
						},
						{
							label: "一月前",
							value: "5"
						}
					]
				}
			],
			category: [],
			groupsProps: {
				label:"eventName",
				value: "eventType"
			},
			apiObj: this.$API.system.sysLog.getAllSysLogListBySafetyAuditor,
			search: {
				date:'',
				accountId:'',
				keyword: "",
				eventType:""
			}
		}
	},
	mounted() {
		this.getSysEventTree();
	},
	methods: {
		//加载树数据
		async getSysEventTree(){
			this.showGrouploading = true;
			var res = await this.$API.system.sysEvent.getSysEventTree.get();
			this.showGrouploading = false;
			this.category = res.data;
		},
		filterChange(data){
			this.search.date = data.date;
			this.$refs.table.upData(this.search)
		},
		updateLog(item)
		{
			if(item.parentId!='0')
			{
				this.search.eventType = item.eventType;
				this.$refs.table.upData(this.search)
			}
		},
		async upsearch() {
			this.$refs.table.upData(this.search)
		},
	}
}
</script>

<style>
</style>
